home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / wexmast / wslider.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  80 lines

  1. ; $Id: wslider.pro,v 1.3 1997/01/15 04:29:15 ali Exp $
  2. ;
  3. ; Copyright (c) 1993-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. ; This is the code for a simple slider.  Moving the slider in this
  7. ; example causes the slider's new value to be printed in the IDL
  8. ; window.
  9. ;
  10. ; Sliders come in two varieties, horizontal (the default) and
  11. ; vertical.  For an example of a vertical slider, see the routine
  12. ; WVERTICAL.PRO.
  13.  
  14. ; Sliders are used to select integer values from 
  15. ; a well-bounded range.  For example, a slider is a good widget
  16. ; to use for allowing users to select a color from an 8-bit palette.
  17. ; For an example of just such an application, see the routine
  18. ; WORLDROT.PRO available from the 'Simple Widget Examples' widget
  19. ; by selecting 'World Rotation Tool'.
  20.  
  21.  
  22. PRO wslider_event, event
  23. ; This is the event handler for a basic slider.
  24.  
  25. ; Use WIDGET_CONTROL to get the user value of any widget touched and put
  26. ; that value into 'eventval':
  27.  
  28. WIDGET_CONTROL, event.id, GET_UVALUE = eventval
  29.  
  30. ; The movement of sliders is easily handled with a CASE statement.
  31. ; When the slider is moved, the value of 'eventval' becomes 'SLIDE':
  32.  
  33. CASE eventval OF
  34.     'SLIDE':BEGIN
  35.         
  36.         ; Get the current value of the slider and put it in the
  37.         ; variable 's':
  38.         WIDGET_CONTROL, event.id, GET_VALUE = s
  39.         
  40.         ; Print the slider value to the IDL window:
  41.         PRINT, 'Horizontal Slider Value = ' + STRING(s)
  42.         END
  43. ENDCASE
  44. END
  45.  
  46.  
  47.  
  48. PRO wslider, GROUP = GROUP
  49. ; This is the procedure that creates a single, horizontal  slider.
  50.  
  51. ; A top-level base widget with the title "Slider Example" will
  52. ; hold the slider:
  53.  
  54. base = WIDGET_BASE(TITLE = 'Slider Example', /COLUMN)
  55.  
  56. ; Often, a slider's minimum and maximum values are defined by an expression:
  57.  
  58. minvalue = 0
  59. maxvalue = 100
  60.  
  61. ; A widget called 'slider' is created. It has the title 'Slider Widget', 
  62. ; a frame around it, and a user value of 'SLIDE':
  63.  
  64. slider = WIDGET_SLIDER(base, $
  65.             MINIMUM = minvalue, $
  66.             MAXIMUM = maxvalue, $
  67.                 TITLE = 'Slider Widget', $
  68.             /FRAME, UVALUE = 'SLIDE',$
  69.             XSIZE = 300) 
  70.  
  71. ; Realize the widgets:
  72. WIDGET_CONTROL, base, /REALIZE
  73.  
  74. ; Hand off control of the widget to the XMANAGER:
  75. XMANAGER, "wslider", base, GROUP_LEADER = GROUP, /NO_BLOCK
  76.  
  77. END
  78.  
  79.  
  80.